#! /usr/bin/env python
# ______________________________________________________________________
"""mython - Python-like front end for the Mython language.

FIXME: Currently just compiles first argument as __main__, possibly
running the module.  This should bloom into something that behaves as
closely to the python executable as possible.

Jonathan Riehl

$Id$
"""
# _____________________________________________________________________
# Module imports

import sys, types
import os
from basil.lang.mython.MyFrontUtils import toplevel_compile

# ______________________________________________________________________

def main (*args):
    """main() - Main routine for the mython script."""
    assert len(args) >= 1
    script_path = os.path.abspath(os.path.split(args[0])[0])
    sys.path.insert(0, script_path)
    # XXX Should we get rid of the sys.path entry for mython itself?
    co, _ = toplevel_compile(args[0])
    m = types.ModuleType("__main__")
    exec co in m.__dict__

# ______________________________________________________________________

if __name__ == "__main__":
    main(*sys.argv[1:])

# ______________________________________________________________________
# End of mython
